#include <assert.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/time.h>
 
// 1秒等于1000毫秒，等于1000000微秒
int main()
{
    float time_use = 0;
    struct timeval start;
    struct timeval end;
    gettimeofday(&start, NULL);
    printf("start.tv_sec:%ld\n", start.tv_sec);
    printf("start.tv_usec:%ld\n", start.tv_usec);
 
    gettimeofday(&end, NULL);
    time_use = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_usec - start.tv_usec);//微秒
    printf("time_use is %f us \n", time_use);
}